<template>
	<view>
		<view class="flex-col" style="height: 100vh;">
			<!-- <view class="ft12 gray6 ptb15 plr15 "><text>{{$t('set').修改所在区域您的提现方式将发生变化}}</text></view> -->
			<view class="bgWhite plr15 flex1 ">
				<view class="ft16 ptb15 bdbe align-center justify-between" @click="confirm(1)">
					<text>{{$t('set').中国大陆}}</text>
					<view v-if="userInfo.area==1">
						<image src="../../static/images/mine/icon/success.png" style="width: 40rpx;height: 40rpx;">
						</image>
					</view>
				</view>
				<view class="ft16 ptb15 bdbe align-center justify-between" @click="confirm(2)">
					<text>{{$t('set').港澳区域}}</text>
					<view v-if="userInfo.area==2">
						<image src="../../static/images/mine/icon/success.png" style="width: 40rpx;height: 40rpx;">
						</image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				active: 0,
				ischange: ''
			}
		},
		computed: {
			userInfo() {
				return this.$store.state.userInfo
			}
		},
		onLoad(option) {
			this.ischange = option.ischange
		},
		onShow() {
			uni.setNavigationBarTitle({
				title: this.$t('set').区域设置
			})
		},
		methods: {
			async confirm(area) {
				if (area == 1) {
					uni.setStorageSync('currency', 'CNY')
					uni.setStorageSync('lang', {
						title: '繁体中文',
						lang: 'zh'
					})
					this.$i18n.locale = 'zh'
					uni.setNavigationBarTitle({
						title: this.$t('set').区域设置
					})
				}
				if (area == 2) {
					uni.setStorageSync('currency', 'USD')

				}
				const res = await this.$api.profile({
					area: area
				})
				if (res && res.code == 1) {
					this.$utils.msg('设置成功')
					await this.$store.dispatch('getuserInfo')
					this.$store.dispatch('changecCrrency')
					// setTimeout(() => {

					// }, 500)
					if (!this.ischange) {} else {
						if (area == 1) {
							if (this.userInfo.sign_status == 1) {
								setTimeout(() => {
									uni.reLaunch({
										url: '/pages/wallet/bindCard'
									})
								}, 300)
							} else {
								this.navTo()
								setTimeout(() => {
									uni.reLaunch({
										url: `/pages/wallet/withdraw`
									})
								}, 300)
							}
						}
					}
				}
			}
		}
	}
</script>

<style>

</style>